﻿using System;
using System.Web;
using System.Web.UI;
using Meqs.Entity;

/// <summary>
/// BasePage 的摘要说明
/// </summary>
public class ContainerBasePage : Page
{
    /// <summary>
    /// 学校标识
    /// </summary>
    public static string SchoolMark
    {
        get
        {
            //HttpContext.Current.Session["UserInfo"] = AppPerm;

            if (HttpContext.Current.Session["UserInfo"] == null)
                throw new Exception("Session已过期，请重新登录");
            return ((Perm)HttpContext.Current.Session["UserInfo"]).SchoolMark;
        }
    }

    /// <summary>
    /// 教师ID
    /// </summary>
    public static int TeacherID
    {
        get
        {
            //HttpContext.Current.Session["UserInfo"] = AppPerm;

            if (HttpContext.Current.Session["UserInfo"] == null)
                throw new Exception("Session已过期，请重新登录");
            return ((Perm)HttpContext.Current.Session["UserInfo"]).UID;

            //HttpContext.Current.Session["TeacherID"] = 6;
            //return (HttpContext.Current.Session["TeacherID"] == null || HttpContext.Current.Session["TeacherID"].ToString() == "") ?
            //            0 :
            //            int.Parse(HttpContext.Current.Session["TeacherID"].ToString());
        }
    }

    /// <summary>
    /// 学生ID
    /// </summary>
    public static int StudentID
    {
        get
        {
            //HttpContext.Current.Session["UserInfo"] = AppPerm;

            if (HttpContext.Current.Session["UserInfo"] == null)
                throw new Exception("Session已过期，请重新登录");
            return ((Perm)HttpContext.Current.Session["UserInfo"]).UID;


            //HttpContext.Current.Session["StudentID"] = 1;

            //return (HttpContext.Current.Session["StudentID"] == null || HttpContext.Current.Session["StudentID"].ToString() == "") ?
            //            0 :
            //            int.Parse(HttpContext.Current.Session["StudentID"].ToString());
        }
    }

    /// <summary>
    /// 登陆信息
    /// </summary>
    public static Perm AppPerm
    {
        get
        {
            Perm perm = new Perm();
            perm.DataUserName = "A00002";
            perm.SchoolMark = "A00002";
            perm.UserType = 4;
            if (perm.UserType == 4)
            { // 教师用户
                perm.UID = 725;
            }
            else if (perm.UserType == 5)
            { // 学生用户
                perm.UID = 1;
            }
            perm.School_Tech_EvalSet = true;
            perm.School_Tech_Report = true;
            perm.School_Tech_TableSet = true;
            perm.School_Tech_StuEval = true;

            //HttpContext.Current.Session["UserInfo"] = perm;

            return HttpContext.Current.Session["UserInfo"] == null ? new Perm() : (Perm)HttpContext.Current.Session["UserInfo"];
        }
    }

    public static int EvalType
    { 
        get
        {
            if (HttpContext.Current.Session["EvalType"].ToString() == "teacher")
                return 0;
            else if (HttpContext.Current.Session["EvalType"].ToString() == "student")
                return 1;
            return -1;
        }
    }
}
